# -*- coding = utf-8 -*-
# @Time : 2022/1/20 23:11
# @Author : GHHHHHHHHH
# @File : datasetHandle.py
# @Software : PyCharm
import sys

import pandas as pd

def datasetHandle(filepath):
    initialDataset = pd.read_csv(filepath)
    dataset = {}
    for key, value in dict(initialDataset).items():
        value = list(value)
        if key == 'timestamp':
            continue
        if key == 'userId':
            dataset[key] = value
            continue
        if key == 'movieId':
            dataset[key] = [i % 18 for i in value]
            continue
        if key == "rating":
            temp = [0 for i in range(len(value))]
            for i in range(len(value)):
                temp[i] += value[i]
            dataset[key] = temp
    pd.DataFrame(dataset).to_csv("1.csv")
    return dataset

datasetHandle("./dataset/movielens100k.csv")